How to make a Checkbox Readonly

Description

Learn how client-side enable expressions can be used to disable a checkbox, making it readonly.

A checkbox HTML element doesn't have a "readonly" property. Consequently, the only way to make a checkbox appear to be "readonly" is to disable the control. A checkbox control can be disabled in Alpha Anywhere using Client-side Enable Expressions.

Client-side enable expressions can be used to disable controls, creating a "readonly" effect. This method can be applied to a checkbox control in a component. The client-side enable expression can be a constant value or based on values in other fields in your component.

images/checkboxReadonly_enableExpression.png

Creating a Static Client-side Enable Expression

If the checkbox control should always be readonly, define the checkbox control's Enable expression as "1=0". The expression, "1=0", will always be false. When a Enable expression evaluates to false, the control will be disabled.

1=0

Creating a Dynamic Client-side Enable Expression

If the checkbox control should be readonly only when data in another field in the component is a specific value, you can specify a dynamic Enable expression that references the field. Click the button for the checkbox control's Enable expression property to open the client-side expression builder. Use the Insert Field to insert a control into the expression. For example, the following expression will disable the checkbox control unless the value in the State field is 'MA':

State = 'MA'
images/checkboxReadonly_dynamic.png

See Also